Add: Implement Merge Sort algorithm in C++ #183
Conversation
|
🎉 Welcome to Hacktoberfest 2025, @Karanjot786! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon. 🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests✅ Passed - All code compiles successfully! 📋 Overall Status🎉 Ready for Review - Your PR has passed all automated checks! This comment was generated automatically. Checks will re-run when you push new commits. |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a complete Merge Sort algorithm in C++ as part of Hacktoberfest 2025 contributions. The implementation follows the divide-and-conquer approach with comprehensive documentation and example usage.
Key Changes
- Added complete merge sort implementation with O(n log n) time complexity
- Included well-documented functions with detailed comments and parameter descriptions
- Provided example usage, test cases, and expected outputs
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| cout << "Original array: "; | ||
| printArray(arr); | ||
|
|
||
| mergeSort(arr, 0, arr.size() - 1); |
There was a problem hiding this comment.
Potential integer underflow when arr.size() is 0. Since arr.size() returns size_t (unsigned), subtracting 1 from 0 results in a very large positive number. This should be guarded with an empty array check or cast arr.size() to int before subtraction.
| mergeSort(arr, 0, arr.size() - 1); | |
| if (!arr.empty()) { | |
| mergeSort(arr, 0, arr.size() - 1); | |
| } |
|
|
||
| #include <iostream> | ||
| #include <vector> | ||
| using namespace std; |
There was a problem hiding this comment.
[nitpick] Using 'using namespace std;' in header files or example code is considered bad practice as it pollutes the global namespace. Consider using specific using declarations like 'using std::vector;' or fully qualified names.
|
🎉 Welcome to Hacktoberfest 2025, @Karanjot786! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon. 🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests✅ Passed - All code compiles successfully! 📋 Overall Status🎉 Ready for Review - Your PR has passed all automated checks! This comment was generated automatically. Checks will re-run when you push new commits. |
🎃 Hacktoberfest 2025 Contribution
📌 Summary
This PR adds a comprehensive implementation of the Merge Sort algorithm in C++ to enhance the repository's
sorting algorithms collection.
🚀 What's Added
CPP/algorithms/sorting/merge_sort.cpp📊 Algorithm Details
✨ Key Features
🧪 Testing
The implementation includes test cases for:
📚 Code Quality
🎯 Contribution Type